
//-------------------------------
// TABLE A1
//-------------------------------

clear
use masterdata_policing.dta

gen vcrime_tot = murders + agg_assault + forc_rape + robbery
gen vcrime_clear = murders_clear + agg_assault_clear + forc_rape_clear + robbery_clear
gen vcrimeclearrate = vcrime_clear/vcrime_tot
gen pcrime_tot = burglary + larcenytheft + mvt
gen pcrime_clear = burglary_clear + larceny_clear + mvt_clear
gen pcrimeclearrate = pcrime_clear/pcrime_tot

gen youthratio = (pop15to17+pop18to24+pop25to34)/totalpopulation
gen blackratio = black/totalpopulation
gen lessthanhighratio = lessthanhigh/popover25
gen unempratio = unemployed/totalpopulation

encode state, gen(state2)
encode county, gen(county2)
set matsize 10000

gen lpop = ln(totalpopulation +1)
gen lincome = ln(medianincome + 1)

gen polbudgetpc = totalbudget/population
gen totpolemppc =(fullswornofficer + fullcivilianemp + ptimeswornofficer + ptimecivilianemp)/population
gen swpolemppc = (fullswornofficer + ptimeswornofficer)/population
gen swfullpolemppc = fullswornofficer/population 

// Change variable unit as %
replace vcrimeclearrate = vcrimeclearrate*100
replace pcrimeclearrate = pcrimeclearrate*100
replace policebudget = policebudget*100
replace youthratio = youthratio*100
replace blackratio = blackratio*100
replace lessthanhighratio = lessthanhighratio*100
replace unempratio = unempratio*100
replace gini = gini*100

macro define crime "vcrime_tot vcrimeclearrate murders agg_assault forc_rape robbery pcrime_tot pcrimeclearrate burglary larcenytheft mvt"
macro define finance "pcttotaligrevenue pcttotaltaxes pctfinesandforfeits finesandforfeitspcp policebudget"
macro define finance2 "pcttotaligrevenue pcttotaltaxes pctfinesandforfeits finesandforfeitspcp policebudget polbudgetpc totpolemppc" 
macro define demographic "lpop youthratio blackratio lessthanhighratio unempratio gini lincome commutemin"

tabstat $crime $finance2 $demographic, stat(N mean sd min max) col(stat)




